package com.kaifamiao.dispatch;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/dan")
public class DanServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        this.log("阿丹");

        // 用 请求对象 的 setAttribute(String, Object) 设置属性
        request.setAttribute( "type" , "重点客户" );

        // 指定 去往哪个资源 对应的路径
        final String path = "/shuang";
        // 获得 用于去往 指定资源 的 请求派遣器
        RequestDispatcher dispatcher = request.getRequestDispatcher( path );
        // 将 请求 和 响应 转发(即派遣) 到 指定资源
        dispatcher.forward(request, response);
        return;
    }

}
